define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'manageuser.user/index',
        add_url: 'manageuser.user/add',
        edit_url: 'manageuser.user/edit',
        delete_url: 'manageuser.user/delete',
        export_url: 'manageuser.user/export',
        modify_url: 'manageuser.user/modify',
        adopt_url: 'manageuser.user/adopt_url',
    };
    var Controller = {
        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh'],
                cols: [[
                    {field: 'id', title: 'ID', search: false},
                    {field: 'nickname', title: '用户昵称'},
                    {field: 'avatar', minWidth: 80, title: '头像', search: false, templet: ea.table.image},
                    {field: 'user_building_number', title: '楼号', search: false},
                    {field: 'user_unitarea', title: '户型面积', search: false},
                    {field: 'status', title: '用户状态', templet: ea.table.switch, search: false},
                    {field: 'create_time', title: '注册时间', search: false},
                    {title: '操作', templet: function (d) {
                            if(d.is_check){
                                return '<button class="layui-btn layui-btn-normal layui-btn-sm layui-btn-disabled" >已设置</button>';
                            }else{
                                return '<button class="layui-btn layui-btn-xs layui-btn-success" data-open="manageuser.user/adopt_url?id='+d.id+'"  data-title="设置参团信息" >设置参团信息</button>';
                            }
                        }
                    },
                ]],
            });
            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
        adopt_url: function () {
            ea.listen();
        },
    };
    return Controller;
});